'use strict';

/**
 *  本文件用于开发测试配置
 *  上线后需要改:
 *    ENVIRONMENT-> deploy,
 *  测试服务器的打包: 
 *    ENVIRONMENT-> beta,
 *  本地测试可改:
 *    ENVIRONMENT-> dev,
 */
import { ENVIRONMENT } from '@/util/config';
import { d_uniShowToast, SHORT_TOAST_DURATION } from './misc';
import { uniReLaunch } from '@/util/funcs';


export let TESTING = ['dev', 'development'].includes(ENVIRONMENT); // 开发人员测试
export let BETA_TEST = TESTING; // 内测专用, 测试人员测试

/**
 * testUser说明: 配置测试人员
 * 用户列表
 *  - jzy
 *  - zy
 *  - ysl
 *  - apple
 *
 * 招商用户列表
 * jzyM - 招商jzy
 * yslM - 招商ysl
 * merchant - 招商魂
 * wyz - 吴彦祖/zsry4
 * zsrA - 招商人Al
 * runtu - 闰土
 */
let clientUser = 'jzy';

import { USER_ORIENTED } from '@/util/config';
export let testUser = USER_ORIENTED ? clientUser : 'yslM';

// 在手机端想测试的用户
// #ifdef APP-PLUS
testUser = USER_ORIENTED ? clientUser : 'jzyM'; // 为了让手机登录另一个用户
// #endif

export function TestUserData() {
  // console.log('testUser', testUser);
  if (TESTING) {
    // console.log(testUser);
    switch (testUser) {
      case 'apple':
        return {
          phone: '17872025300',
          password: 'Password1',
        };
      case 'jzy':
        return {
          phone: '13011807250',
          password: 'Password1',
        };
      case 'zy':
        return {
          phone: '17520480086',
          password: 'Aa123456',
        };
      case 'ysl':
        return {
          phone: '15675846466',
          password: 'Password1',
        };
      //------------------------------------------------ 两端测试用户分界线
      case 'runtu':
        return {
          phone: '17520480846',
          password: 'zsry123',
        };
      case 'zyM':
        return {
          phone: '17520480086',
          password: 'yyy111',
        };
      case 'jzyM':
        return {
          phone: '13011807250',
          password: 'Password1',
        };
      case 'yslM':
        return {
          phone: '15675846466',
          password: 'Password1',
        };
      case 'zsrA':
        return {
          phone: '15611111111',
          password: 'Password1',
        };

      case 'merchant':
        return {
          phone: '18318938974',
          password: 'qckj123',
        };
      case 'wyz':
        return {
          phone: '16512341234',
          password: 'aaa111',
        };
    }
  } else {
    return {
      phone: '',
      password: '',
    };
  }
}

// 测试与后台发送短信
export const TEST_WITH_PC = false && TESTING;
// 双端测试聊天
export const TEST_WITH_PORTAL = false && TESTING;
export const CHAT_IGNORE_BADGE_COUNT = false && TESTING;

export async function toggle_TESTING() {
  TESTING = !TESTING;
  BETA_TEST = !BETA_TEST;
  if (TESTING) {
    d_uniShowToast({
      title: '快速测试模式',
      duration: SHORT_TOAST_DURATION,
    });
  } else {
    await uniReLaunch('/home/home');
    d_uniShowToast({
      title: '真实模式',
      duration: SHORT_TOAST_DURATION,
    });
  }
}

export function setTestUser(name) {
  testUser = name;
}

